home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Programmer Disk
/
The Programmer Disk (Microforum).iso
/
xpro
/
qb2
/
pro16
/
tabman.bas
< prev
next >
Wrap
BASIC Source File
|
1992-01-02
|
4KB
|
121 lines
' TabMan.Bas - Tab handling functions that handle both
' fixed-interval and irregular-interval tab stops.
' The fixed-interval mode computes tab stops on
' the fly, while the irregular-interval mode
' uses the Bit Array package routines to allow you
' to specify multiple, irregular tab stops.
' $INCLUDE: 'TABMAN.BI'
' $INCLUDE: 'BITLIST.BI' '**IRREG
DIM SHARED TabList AS INTEGER '**IRREG
DIM SHARED TabSize AS INTEGER '**FIXED
DIM SHARED TabStyle AS INTEGER '**BOTH
SUB ClrTab (TabStop AS INTEGER)
' ClrTab - Clear the specified tab stop position.
IF TabStop = -1 THEN '**IRREG
X% = blListOp(blClear, TabList, 0) '**IRREG
ELSE '**IRREG
X% = blSetBit(TabList, TabStop - 1, 0) '**IRREG
END IF '**IRREG
END SUB
SUB DeTab (Hastabs$, Notabs$)
' DeTab - Take the tabs out & replace w/correct of spaces
Notabs$ = ""
I% = 1: J% = 1
DO WHILE I% <= LEN(Hastabs$)
IF MID$(Hastabs$, I%, 1) <> CHR$(9) THEN
Notabs$ = Notabs$ + MID$(Hastabs$, I%, 1)
J% = J% + 1
ELSE
DO WHILE NOT IsTab(J%)
Notabs$ = Notabs$ + " "
J% = J% + 1
LOOP
END IF
I% = I% + 1
LOOP
END SUB
SUB EnTab (Notabs$, Hastabs$)
' EnTab - Subprogram to tabify a string
Hastabs$ = ""
I% = 1
DO WHILE I% <= LEN(Notabs$)
IF MID$(Notabs$, I%, 1) <> " " THEN
Hastabs$ = Hastabs$ + MID$(Notabs$, I%, 1)
I% = I% + 1
ELSE
DO WHILE MID$(Notabs$, I%, 1) = " "
IF IsTab%(I% + 1) THEN
Hastabs$ = Hastabs$ + CHR$(9)
CS% = 0
ELSE
CS% = CS% + 1
END IF
I% = I% + 1
LOOP
IF CS% THEN
Hastabs$ = Hastabs$ + STRING$(CS%, " ")
CS% = 0
END IF
END IF
LOOP
END SUB
SUB InitTabManager (Style AS INTEGER)
' InitTabManager - Initialize the tab manager package.
' Specify TabStyle as 1 for fixed-interval tabs,
' or specify 2 for irregular-intewrval tab stops.
TabStyle = Style '**BOTH
IF Style = 2 THEN '**BOTH
TabList = blCreate(MAXTAB) '**IRREG
END IF '**BOTH
END SUB
FUNCTION IsTab% (TabStop AS INTEGER)
' IsTab - Function to see if there is a tab stop
' at the specified position. Returns TRUE if so,
' FALSE if no tab stop there.
IF TabStyle = 1 THEN '**BOTH
IsTab% = ((TabStop - 1) MOD TabSize = 0) '**FIXED
ELSE '**BOTH
IF TabStop > MAXTAB THEN '**IRREG
IsTab% = TRUE '**IRREG
ELSE '**IRREG
IsTab% = (blGetBit(TabList, TabStop - 1) <> 0) '**IRREG
END IF '**IRREG
END IF '**BOTH
END FUNCTION
SUB SetTab (TabStop AS INTEGER)
' SetTab - Set a tab stop at the specified position
IF TabStyle = 1 THEN '**BOTH
TabSize = TabStop '**FIXED
ELSE '**BOTH
X% = blSetBit(TabList, TabStop - 1, 1) '**IRREG
END IF '**BOTH
END SUB